<style lang="less">
.card_style {
  height: 100%;
  width: 100%;
  overflow: hidden;
  .ivu-card-body {
    padding: 0px;
  }
}
.page_style {
  margin-top: 10px;
  text-align: right;
}
.bench_search {
  margin-bottom: 10px;
}
.nopadding .ivu-table-cell {
  padding: 0px 0px;
}
.item1 {
  height: 42px;
  line-height: 40px;
}
.marginR2 {
  margin-right: 2%;
}
.fontsize20 {
  font-size: 20px;
}
.fontTitle {
  font-size: 20px;
  height: 52px;
  text-align: right;
  padding-top: 16px;
  // vertical-align: bottom;
}
.fontContent {
  font-size: 20px;
  height: 52px;
  text-align: left;
  padding-top: 16px;
  color: #dc9387;
  // vertical-align: bottom;
}
.countNum {
  font-size: 35px;
  color: #dc9387;
}
.new-btn-sty {
  margin-right: 5px;
  color: #fff;
  background-color: #235ca7;
  border-color: #235ca7;
  font-weight: 500;
}
.new-btn-sty1 {
  margin-right: 5px;
  color: #fff;
  background-color: #598ed1;
  border-color: #598ed1;
  font-weight: 500;
}
.text-overflow {
  width: 300px; /* 超过宽度就显示... */
  text-overflow: ellipsis; /* 显示... */
  overflow: hidden; /* 隐藏文字 */
  white-space: nowrap; /* 不换行 */
  cursor: pointer; /* hover显示手形 */
}
.search-info-style {
  margin-top: 10px;
}
.table-input {
  border: #312e2e solid 1px;
  border-left: 0px;
  border-right: 0px;
  line-height: 50px;
}
.table-col {
  border: #312e2e solid 1px;
  line-height: 50px;
}
.demo-drawer-footer {
  margin-top: 80px;
}
</style>
<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <Row class="search-info-style">
      <Col span="6">
      <span style="">服务类别：</span>
      <Select @on-change="selectOnconfrim"
              v-model="searchInfo.category_name"
              filterable
              transfer=""
              style="width: 70%;">
        <Option v-for="(item,index) in obtainDataList"
                :key="index"
                :value="item.category_name">{{item.category_name}}</Option>
      </Select>
      </Col>
      <Col span="12">
      <span>评价时间段：</span>
      <DatePicker type="date"
                  v-model="searchInfo.start_time"
                  placeholder="选择开始时间"
                  style="width: 30%;"></DatePicker>
      ～ <DatePicker type="date"
                  v-model="searchInfo.end_time"
                  placeholder="选择结束时间"
                  style="width: 30%;"></DatePicker>
      </Col>
      <!-- <Col span="6">
        <span style="">审批人：</span>
        <Input style="width: 70%;" v-model="searchInfo.operator" />
      </Col> -->
      <!--      <Col span="3">-->
      <!--        ～ <DatePicker type="date" v-model="searchInfo.end_time" placeholder="选择结束时间" style="width: 50%;"></DatePicker>-->
      <!--      </Col>-->
      <Col style="float:right"
           pull="1">
      <Button class="new-btn-sty"
              @click="init()">
        <Icon type="ios-search" />查询
      </Button>
      <Button class="new-btn-sty"
              @click="searchDatawork()">
        <Icon type="ios-search" />重置
      </Button>
      </Col>
    </Row>
    <!-- <Row class="search-info-style">
      <Col span="6">
        <span>类别编号：</span>
        <Select v-model="searchInfo.result" filterable transfer="" style="width: 70%;">
          <Option value="">全部</Option>
          <Option value="0">驳回</Option>
          <Option value="1">通过</Option>
          <Option value="2">审批中</Option>
        </Select>
      </Col>
      <Col span="6">
        <span>服务条目：</span>
        <Select v-model="searchInfo.result" filterable transfer="" style="width: 70%;">
          <Option value="0">社会组织公共服务</Option>
          <Option value="1">民政</Option>
          <Option value="2">人力资源社会保障</Option>
          <Option value="3">房产</Option>
          <Option value="4">卫生健康</Option>
          <Option value="5">医保</Option>
          <Option value="6">工会</Option>
          <Option value="7">残联</Option>
          <Option value="8">社区证明</Option>
          <Option value="9">其他</Option>
        </Select>
      </Col>
    </Row> -->

    <Col style="margin-top:20px"
         pull="-10">
    <Button class="new-btn-sty"
            @click="addNew()">
      <Icon type="ios-add" />新增
    </Button>
    <!-- <Button class="new-btn-sty" @click="searchDatawork()"><Icon type="ios-search" />编辑</Button> -->
    </Col>
    <Row>
      <Col span="24">
      <Table border
             :columns="columns"
             :data="datalist"
             ref="personSelection"
             style="margin-top:10px;"
             @on-selection-change="personSelection()">
        <template slot-scope="{ row }"
                  slot="event_type">
          <span v-if="row.event_type == '1'">新增</span>
          <span v-if="row.event_type == '2'">注销</span>
          <span v-if="row.event_type == '3'">跨街道调动</span>
          <span v-if="row.event_type == '4'">街道内调动</span>
          <span v-if="row.event_type == '5'">区内调动</span>
          <span v-if="row.event_type == '6'">跨区调动</span>
        </template>
        <template slot-scope="{ row }"
                  slot="stateOpen">
          <span v-if="row.open_state == '1'">已暂停</span>
          <span v-if="row.open_state == '0'">已开启</span>

        </template>
        <template slot-scope="{ row }"
                  slot="result">
          <span>{{ timeParse(row.start_time,'{y}-{m}-{d} ')}} — {{timeParse(row.end_time,'{y}-{m}-{d} ')}}</span>
        </template>
        <template slot-scope="{ row }"
                  slot="sex">
          <span v-if="row.sex == '0'">男</span>
          <span v-if="row.sex == '1'">女</span>
        </template>
      </Table>
      <Row v-if="searchInfo.loading1 == true">
        <Col class="demo-spin-col"
             span="8"
             offset="8">
        <Spin fix>
          <Icon type="ios-loading"
                size=18
                class="demo-spin-icon-load"></Icon>
          <div>数据正在加载</div>
        </Spin>
        </Col>
      </Row>
      </Col>
    </Row>
    <Page :total="searchInfo.totalnum"
          class="page_style"
          :current="searchInfo.currentPageNo"
          :page-size="searchInfo.currentPageSize"
          @on-change="changePageNo"
          show-total
          show-elevator
          show-sizer
          @on-page-size-change="changePagesize" />
    <Modal v-model="processModal"
           title="流程跟踪"
           width="80%">
      <Row>
        <Col span="24">
        <Table border
               :columns="processColumns"
               :data="processlist"
               ref="personSelection"
               style="margin-top:10px;"
               @on-selection-change="personSelection()">
          <template slot-scope="{ row }"
                    slot="state">
            <span v-if="!row.state">无结点</span>
            <span v-if="row.state == '1'">调入地审批</span>
            <span v-if="row.state == '2'">区审批</span>
            <span v-if="row.state == '3'">街道审批</span>
            <span v-if="row.state == '4'">市审批</span>
          </template>
          <template slot-scope="{ row }"
                    slot="result">
            <span>{{ timeParse(row.start_time,'{y}-{m}-{d} ')}} — {{timeParse(row.end_time,'{y}-{m}-{d} ')}}</span>
          </template>
        </Table>
        <Row v-if="searchInfo.loading1 == true">
          <Col class="demo-spin-col"
               span="8"
               offset="8">
          <Spin fix>
            <Icon type="ios-loading"
                  size=18
                  class="demo-spin-icon-load"></Icon>
            <div>数据正在加载</div>
          </Spin>
          </Col>
        </Row>
        </Col>
      </Row>
    </Modal>
    <Modal v-model="modal" title="驳回原因" :mask-closable="false">
      <form>
        <div style="text-align: center">
          驳回原因：<Input v-model="reason"
                 type="textarea"
                 placeholder="驳回原因"
                 style="width: 300px" />
        </div>
      </form>
      <div slot="footer">
        <Button type="info"
                @click="ok()">提交</Button>
        <Button type="default"
                @click="closeModel()">退出</Button>
      </div>
    </Modal>

    <Modal v-model="okModel" title="通过审批-选社区提交区" :mask-closable="false">
      <form>
        <Select v-model="operator">
          <Option :value="item.code"
                  v-for="item in mailList3"
                  v-bind:key="item.code">{{item.name}}</Option>
          <!--          <Option v-for="(item, index) in communityList" :value="item.CPSR001" :key="index">{{ item.CPSR002 }}</Option>-->
        </Select>
      </form>
      <div slot="footer">
        <Button type="info"
                @click="submitOk()">提交</Button>
        <Button type="default"
                @click="closeSubmitOk()">退出</Button>
      </div>
    </Modal>

    <!-- 新增 -->
    <Drawer title="评价机制条目新增"
            v-model="drawer1"
            width="720">
      <Form :model="formData">

        <Row :gutter="32">
          <Col span="18">

          <Col span="12">
          <span>服务类别：</span>
          <Select @on-change="selectOnconfrim"
                  v-model="formData.category_name"
                  filterable
                  :disabled="showEdit"
                  transfer=""
                  style="width: 70%;">
            <Option v-for="(item,index) in obtainDataList"
                    :key="index"
                    :value=" showEdit ? formData.category_name : item.category_name">{{ showEdit ?  formData.category_name : item.category_name}}</Option>
          </Select>
          </Col>
          </Col>
        </Row>

        <Row style="margin-top:20px"
             :gutter="32">
          <Col span="18">

          <FormItem label="类别条目："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="formData.entry_name"
                   placeholder="请填写类别条目：" />
          </FormItem>
          </Col>
        </Row>


        <Row 
             :gutter="32">
          <Col span="18">

          <FormItem label="条目描述："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="formData.entry_describe"
                   placeholder="请填写条目描述：" />
          </FormItem>
          </Col>
        </Row>

        <Row :gutter="32">
          <Col span="24">
          <FormItem label="类别编号："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input disabled
                   v-model="formData.categoryNo"
                   placeholder="请填写类别编号" />
          </FormItem>
          </Col>
        </Row>

        <!-- <Col span="6">
        <span>类别编号：</span>
        <Select v-model="searchInfo.result" filterable transfer="" style="width: 70%;">
          <Option value="">全部</Option>
          <Option value="0">驳回</Option>
          <Option value="1">通过</Option>
          <Option value="2">审批中</Option>
        </Select>
      </Col> -->

        <Row :gutter="32">
          <Col span="24">
          <FormItem label="评分范围："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input disabled
                   v-model="overData"
                   placeholder="请填写评分范围" />
          </FormItem>
          </Col>
        </Row>

        <Row :gutter="32">
          <Col span="24">
          <span>评价时间段：</span>
          <DatePicker type="date"
                      v-model="formData.start_time"
                      placeholder="选择开始时间"
                      style="width: 30%;"></DatePicker>
          <DatePicker type="date"
                      v-model="formData.end_time"
                      placeholder="选择结束时间"
                      style="width: 30%;"></DatePicker>
          </Col>
        </Row>

        <Row :gutter="32">
          <Col span="12">
          <FormItem label="条目机制内容："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="scoreList.entry_content[0]"
                   placeholder="请填写条目机制内容" />

                   
          </FormItem>
          </Col>
          <Col span="6">  
          <FormItem label="分值："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input @on-blur="inputNum"
                  number
                   v-model="scoreList.entry_score[0]"
                   placeholder="请填写分值" />
          </FormItem>
          </Col>
        </Row>

        <Row v-if="!showEdit"
             :gutter="32">
          <Col span="12">
          <FormItem label="条目机制内容："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="scoreList.entry_content[1]"
                   placeholder="请填写条目机制内容" />
          </FormItem>
          </Col>
          <Col span="6">
          <FormItem label="分值："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input @on-change="inputNumOne"
            number
                   v-model="scoreList.entry_score[1]"
                   placeholder="请填写分值" />
          </FormItem>
          </Col>
        </Row>

        <Row v-if="!showEdit"
             :gutter="32">
          <Col span="12">
          <FormItem label="条目机制内容："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="scoreList.entry_content[2]"
                   placeholder="请填写条目机制内容" />
          </FormItem>
          </Col>
          <Col span="6">
          <FormItem label="分值："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input @on-change="inputNumTwo"
            number
                   v-model="scoreList.entry_score[2]"
                   placeholder="请填写分值" />
          </FormItem>
          </Col>
        </Row>

        <Row v-if="!showEdit"
             :gutter="32">
          <Col span="12">
          <FormItem label="条目机制内容："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input v-model="scoreList.entry_content[3]"
                   placeholder="请填写条目机制内容" />
          </FormItem>
          </Col>
          <Col span="6">
          <FormItem label="分值："
                    label-position="top">
            <!-- <Input type="textarea" v-model="formData.experience_content" :rows="4" placeholder="请填写类别编号" /> -->
            <Input @on-change="inputNumThree"
            number
                   v-model="scoreList.entry_score[3]"
                   placeholder="请填写分值" />
          </FormItem>
          </Col>
        </Row>
      </Form>

      <div class="demo-drawer-footer">
        <Button style="margin-right: 8px"
                @click="drawer1 = false">取消</Button>
        <Button type="primary"
                @click="complete(formData.id)">确定</Button>
      </div>
    </Drawer>
  </div>
</template>

<script>
import { updateEvaluationEntry, selectAllEvaluationEntry,selectEntry, selectAllEvaluationCategory, selectEvaluationEntry, insertEvaluationEntryList } from '@/api/workerV2'
import { timeParse } from '@/libs/tools.js'
export default {
  data () {
    return {
      clickType: false, //新增，编辑状态  flase 新增 / true 编辑 
      overData: '1-100',
      showEdit: false,
      timeParse,
      drawer1: false,
      formData: {},
      scoreList: {
        entry_score: [],
        entry_content: []
      },
      mailList1: [],
      mailList2: [],
      mailList3: [],
      modal: false,
      okModel: false,
      operator: '',
      company_code: this.$store.state.user.severUserInfo.company_code,
      level: this.$store.state.user.severUserInfo.company_grade,
      reason: '',
      datalist: [],
      addModal: false,
      updateModal: false,
      showModal: false,
      handle_time1: '',
      deleteModal: false,
      jdnddModal: false,
      kjdddModal: false,
      qnddModal: false,
      kqddModal: false,
      processModal: false,
      ddInfo: {},
      addinfo: {},
      updateinfo: {},
      showinfo: {},
      obtainDataList: [],
      row: '',
      deleteInfo: {},
      handleInfo: {},
      searchInfo: {
        categoryNo: '',
        applytime: [],
        currentPageNo: 1,
        currentPageSize: 10,
        loading1: true
      },
      reginList: [[], [], []],
      dictList: [[], [], []],
      processlist: [],
      communityList: [],
      columns: [
        // {
        //   type: 'index',
        //   width: 50,
        //   align: 'center'
        // },
        // {
        //   type: 'selection',
        //   width: 60,
        //   align: 'center'
        // },
        // { title: '审批流程', key: 'event_type', width: 150, align: 'center', slot: 'event_type' },
        // { title: '发起人员', key: 'company_name', width: 150, align: 'center' },
        // { title: '发起时间', key: 'create_time', width: 160, align: 'center' },
        // { title: '社工姓名', key: 'CPBI003', width: 150, align: 'center' },
        // { title: '性别', key: 'sex', slot: 'sex', width: 80, align: 'center' },
        { title: '服务类别', key: 'category_name', Width: 140, align: 'center' },
        { title: '类别编号', key: 'category_no', width: 140, align: 'center' },
        { title: '服务条目', key: 'entry_name', width: 140, align: 'center' },
        { title: '条目描述', key: 'entry_describe', width: 140, align: 'center' },
        { title: '条目机制', key: 'entry_content', width: 140, align: 'center' },
        { title: '开启状态', slot: 'stateOpen', minwidth: 220, align: 'center' },
        { title: '评价时间段', slot: 'result', minwidth: 220, align: 'center' },
        {
          title: '操作',
          key: 'action',
          minWidth: 110,
          align: 'center',
          render: (h, params) => {
            let temp = []
            temp.push(
              h('Button', {
                props: { type: 'info', size: 'small' },
                style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                on: {
                  click: () => {
                    this.clickType = true
                    this.getFlowItem(params.row.id)
                  }
                }
              }, '编辑')
            )
            if (params.row.open_state == 1) {
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.back(params.row)
                    }
                  }
                }, '启用')
              )
            }

            // state: 1街道  ， state：2区
            if (params.row.open_state == 0) {
              temp.push(
                h('Button', {
                  props: { type: 'error', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.selectCom(params.row)
                    }
                  }
                }, '暂停')
              )
            }
            // else if (params.row.put_place && params.row.state == '1' && params.row.level == '3') {
            //   temp.push(
            //     h('Button', {
            //       props: { type: 'info', size: 'small' },
            //       style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
            //       on: {
            //         click: () => {
            //           this.submitCityOk(params.row)
            //         }
            //       }
            //     }, '通过上报区')
            //   )
            // }
            else if (params.row.put_place && params.row.state == '2' && this.level !== '2' && params.row.event_type === '6') {
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.cityPass(params.row)
                    }
                  }
                }, '区通过')
              )
            } else if (params.row.put_place && params.row.state == '2' && this.level !== '2' && params.row.event_type === '3') {
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      this.cityPass2(params.row)
                    }
                  }
                }, '通过')
              )
            } else if (this.level === '2') {
              // temp.push(
              //   h('Button', {
              //     props: { type: 'info', size: 'small' },
              //     style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
              //     on: {
              //       click: () => {
              //         this.shiPass(params.row)
              //       }
              //     }
              //   }, '暂停')
              // )
            } else {
              // 新增的不用选社区直接通过
              temp.push(
                h('Button', {
                  props: { type: 'info', size: 'small' },
                  style: { marginRight: '5px', marginTop: '2px', marginBottom: '2px' },
                  on: {
                    click: () => {
                      if (confirm('是否确定通过？')) {
                        updatePersonnelPassInfo(params.row).then(ret => {
                          if (ret.data.errcode === 0) {
                            this.$Notice.success({ title: '审批通过', desc: "" })
                            this.init()
                          } else {
                            this.$Notice.error({ title: '审批失败', desc: ret.data.errmsg })
                          }
                        })
                      }
                    }
                  }
                }, '直接通过')
              )
            }
            return h('div', temp)
          }
        }
      ],
      processColumns: [
        {
          title: '序号',
          type: 'index',
          width: 50,
          align: 'center'
        },
        { title: '流程节点', slot: 'state', minWidth: 110, align: 'center' },
        { title: '提交时间', key: 'send_time', minWidth: 120, align: 'center' },
        { title: '发起人员', key: 'send_name', minWidth: 120, align: 'center' },
        { title: '社工人员', key: 'CPBI003', minWidth: 120, align: 'center' },
        { title: '审批人员', key: 'company_name', minWidth: 130, align: 'center' },
        { title: '审批状态', slot: 'result', minWidth: 100, align: 'center' },
        { title: '审批时间', key: 'create_time', minWidth: 120, align: 'center' },
        { title: '审批意见', key: 'reason', minWidth: 220, align: 'center' }
      ]
    }
  },
  methods: {



    debounce(func,wait){
      var timeId = null 
      return function (...args) {
          if(timeId){
            clearTimeout(timeId)
          }
          time = setTimeout(function(){
            func(...args)
          },wait)
      } 
    },



    inputNum (event) {
      console.log('eeee', event)
     
      if (!(/(^[1-9]\d*$)/.test(event.target.value)) || event.target.value > 100) {
        this.$Notice.error({
          title: '请重新输入正确数值',
        })
        this.scoreList.entry_score[0] = 0
      }
    
    },
    inputNumOne (event) {
      console.log('eeee', event)
      if (!(/(^[1-9]\d*$)/.test(event.target.value)) || event.target.value > 100) {
        this.$Notice.error({
          title: '请重新输入正确数值',
        })
        this.scoreList.entry_score[1] = 0
      }
     
       
      
    },
    inputNumTwo (event) {
      console.log('eeee', event)
      if (event.target.value > 100) {
        this.$Notice.error({
          title: '请重新输入正确数值',

        })
        this.scoreList.entry_score[2] = 0
      }
    },
    inputNumThree (event) {
      console.log('eeee', event)
      if (event.target.value > 100) {
        this.$Notice.error({
          title: '请重新输入正确数值',

        })
        this.scoreList.entry_score[3] = 0
      }
    },
    //服务类型选择框选中触发确认事件
    selectOnconfrim (val) {
      console.log('value', val)
      this.formData.category_name = val
      this.searchInfo.categoryName = val
      this.formData.categoryNo = this.valuePassingFilter(val)
      // console.log(' this.formData.category_no',  this.formData.categoryNo)
    },
    //通过传参数返回相对应的值
    valuePassingFilter (parameter) {
      let num
      this.obtainDataList.forEach(item => {
        console.log('item,item', item)
        if (parameter == item.category_name) {
          // console.log('进入循环',item.categoryNo)
          num = item.category_no
          return num
        }

      })
      return num
    },
    async obtainData () {
      let dataList = await selectAllEvaluationCategory()
      this.obtainDataList = dataList.data.data
      console.log('dataList', dataList)
    },
    complete (id) {

      if (this.clickType) {
        const param = {
          id: id,
          category_no: this.formData.categoryNo,
          category_name: this.formData.category_name,
          start_time: this.timeParse(this.formData.start_time, '{y}-{m}-{d} '),
          end_time: this.timeParse(this.formData.end_time, '{y}-{m}-{d} '),
          entry_content: this.scoreList.entry_content[0],
          entry_score: this.scoreList.entry_score[0],
          entry_name: this.formData.entry_name,
          entry_describe:this.formData.entry_describe
        }

        updateEvaluationEntry(param).then(ret => {
          if (ret.data.errcode === 0) {
            this.$Notice.success({
              title: '修改成功',
              // desc: ret.data.errmsg
            })
            this.init()
            this.drawer1 = false
          } else {
            this.$Notice.error({
              title: '修改失败',
              desc: ret.data.errmsg
            })
          }
        })
        return
      }


      console.log('分值', this.scoreList)
      console.log('新增确定', this.searchInfo.event_type)
      const param = {
        category_no: this.formData.categoryNo,
        category_name: this.formData.category_name,
        start_time: this.timeParse(this.formData.start_time, '{y}-{m}-{d} '),
        end_time: this.timeParse(this.formData.end_time, '{y}-{m}-{d} '),
        entry_content: this.scoreList.entry_content[0],
        entry_score: this.scoreList.entry_score[0],
        entry_name: this.formData.entry_name,
        entry_describe:this.formData.entry_describe
      }
      const param1 = {
        category_no: this.formData.categoryNo,
        category_name: this.formData.category_name,
        start_time: this.timeParse(this.formData.start_time, '{y}-{m}-{d} '),
        end_time: this.timeParse(this.formData.end_time, '{y}-{m}-{d} '),
        entry_content: this.scoreList.entry_content[1],
        entry_score: this.scoreList.entry_score[1],
        entry_name: this.formData.entry_name,
        entry_describe:this.formData.entry_describe
      }
      const param2 = {
        category_no: this.formData.categoryNo,
        category_name: this.formData.category_name,
        start_time: this.timeParse(this.formData.start_time, '{y}-{m}-{d} '),
        end_time: this.timeParse(this.formData.end_time, '{y}-{m}-{d} '),
        entry_content: this.scoreList.entry_content[2],
        entry_score: this.scoreList.entry_score[2],
        entry_name: this.formData.entry_name,
        entry_describe:this.formData.entry_describe
      }
      const param3 = {
        category_no: this.formData.categoryNo,
        category_name: this.formData.category_name,
        start_time: this.timeParse(this.formData.start_time, '{y}-{m}-{d} '),
        end_time: this.timeParse(this.formData.end_time, '{y}-{m}-{d} '),
        entry_content: this.scoreList.entry_content[3],
        entry_score: this.scoreList.entry_score[3],
        entry_name: this.formData.entry_name,
        entry_describe:this.formData.entry_describe

      }

      let list = [param, param1, param2, param3]
      const params = {
        list
      }

      insertEvaluationEntryList(params).then(res => {
        console.log('res edit => id', res)
        this.$Notice.success({
          title: '新增成功',
        })
        this.drawer1 = false
      })

    },
    addNew () {
      this.clickType = false
      this.formData = {}
      if (this.scoreList.entry_content.length != 0 || this.scoreList.entry_score.length != 0) {
        console.log('1jinru')
        this.scoreList.entry_content[0] = ''
        this.scoreList.entry_score[0] = ''
      }
      this.showEdit = false
      this.obtainData()
      this.drawer1 = true
    },
    submitOk () {
      // if(!this.operator) {
      //   this.$Notice.error({
      //     title: '社区不可为空'
      //   })
      //   return
      // }
      if (!this.operator) {
        this.operator = this.row.out_place
      }
      let data = {
        id: this.row.id,
        result: '1',
        state: '2',
        operator: this.$store.state.user.severUserInfo.parent_code,
        out_place: this.operator
      }
      // updateFlow(data).then(ret => {
      //   if (ret.data.errcode === 0) {
      //     this.$Notice.success({
      //       title: '成功',
      //       desc: ret.data.errmsg
      //     })
      //     this.operator = ''
      //     this.okModel = false
      //     // this.updatePerson('submitOk')
      //     this.init()
      //   } else {
      //     this.$Notice.error({
      //       title: '失败',
      //       desc: ret.data.errmsg
      //     })
      //   }
      // })
      // 这个给区报
      this.insertLogs('1');
    },
    // 直接报到区
    submitCityOk () {
      let data = {
        id: this.row.id,
        result: '1',
        state: '2',
        operator: this.$store.state.user.severUserInfo.parent_code,
        out_place: this.row.out_place
      }
      // updateFlow(data).then(ret => {
      //   if (ret.data.errcode === 0) {
      //     this.$Notice.success({
      //       title: '成功',
      //       desc: ret.data.errmsg
      //     })
      //     // this.updatePerson('submitOk')
      //     this.init()
      //   } else {
      //     this.$Notice.error({
      //       title: '失败',
      //       desc: ret.data.errmsg
      //     })
      //   }
      // })
      // 这个给区报
      this.insertLogs('1');
    },
    goBack () {
      let data = {
        pid: this.row.pid,
        cp: '11' // 更改状态正常
      }
      updateCP(data).then(ret => {
        if (ret.data.errcode === 0) {
          this.init()
        } else {
          this.$Notice.error({
            title: '修改人员状态失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    closeSubmitOk () {
      this.operator = ''
      this.okModel = false
    },
    // 暂停
    selectCom (row) {

      console.log('row', row)
      // let list =  [{open_state:'0'}]
      // const params = {
      //     list
      // } 
      updateEvaluationEntry({ open_state: '1', id: row.id }).then(ret => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '暂停成功',
            // desc: ret.data.errmsg
          })
          this.init()
        } else {
          this.$Notice.error({
            title: '暂停失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    searchDatawork () {
      this.searchInfo = {}
      this.init()
    },
    shiPass (row) {
      this.row = row
      this.backReason('00')
      this.insertLogs('00')
      this.updatePerson('cityPass')
    },
    // 区通过
    // cityPass(row) {
    //   this.row = row
    //   // this.backReason('00')
    //   // this.insertLogs('00')
    //   // this.updatePerson('cityPass')
    //   if(!this.operator) {
    //     this.operator = this.row.out_place
    //   }
    //   let data = {
    //     id: row.id,
    //     result: '3',
    //     state: '2',
    //     operator: this.$store.state.user.severUserInfo.parent_code,
    //     // out_place: this.operator
    //   }
    //   updateFlow(data).then(ret => {
    //     if (ret.data.errcode === 0) {
    //       this.$Notice.success({
    //         title: '成功',
    //         desc: ret.data.errmsg
    //       })
    //       this.operator = ''
    //       this.okModel = false
    //       // this.updatePerson('submitOk')
    //       this.init()
    //     } else {
    //       this.$Notice.error({
    //         title: '失败',
    //         desc: ret.data.errmsg
    //       })
    //     }
    //   })
    //   // 这个给区报
    //   this.insertLogs('3');
    // },

    cityPass2 (row) {
      this.row = row
      this.backReason('00')
      this.insertLogs('00')
      this.updatePerson('cityPass')
    },
    // 街道通过-等待区通过啊
    go (row) {
      this.row = row
      this.backReason('1');
      this.insertLog('1');
      // this.updatePerson('go')
    },
    // 驳回提交
    ok () {
      if (!this.reason) {
        this.$Notice.error({
          title: '原因不可为空',
          desc: '原因不可为空'
        })
        return
      }
      this.backReason('0');
      if (this.level == '3') {
        this.insertLogs('0');
      } else {
        this.insertLog('0');
      }
      this.goBack()
    },
    closeModel () {
      this.reason = ''
      this.modal = false
    },
    // 通过
    backReason (v) {
      let data = {
        reason: this.reason,
        result: v,
        id: this.row.id
      }
      if (this.level === '2') {
        data.state = '4'
      }
      // updateFlow(data).then(ret => {
      //   if (ret.data.errcode === 0) {
      //     if(v == '00' || v == '1') {
      //       this.$Notice.success({title: '操作成功',desc: ''})
      //     }else{
      //       this.$Notice.success({title: '驳回成功',desc: ''})
      //     }
      //     this.reason = ''
      //     this.modal = false
      //     this.init()
      //   } else {
      //     if(v == '00' || v == '1') {
      //       this.$Notice.success({title: '操作失败',desc: ''})
      //     }else{
      //       this.$Notice.success({title: '驳回失败',desc: ''})
      //     }
      //   }
      // })
    },
    // 区驳回记录
    insertLogs (v) {
      let data = {
        flow_id: this.row.id,
        state: '2',
        result: v,
        reason: this.reason,
        approved_by: this.company_code
      }
      addRecord(data).then(ret => {
        if (ret.data.errcode === 0) {

        } else {
          this.$Notice.error({
            title: '插入日志失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    // 街道驳回记录
    insertLog (v) {
      let data = {
        flow_id: this.row.id,
        state: '1',
        result: v,
        reason: this.reason,
        approved_by: this.company_code
      }
      addRecord(data).then(ret => {
        if (ret.data.errcode === 0) {

        } else {
          this.$Notice.error({
            title: '插入日志失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    // 终止审批成功后进行调用
    updatePerson (str) {
      let data = {
        id: this.row.id,
        pid: this.row.pid,
      }
      if (str == 'submitOk') {
        data.community = this.operator
      } else if (str == 'cityPass' && this.row.event_type == '6') {
        // 1社区，2街道, 3级别工作者协会
        if (this.row.level) {
          if (this.row.level == '3') {
            data.city = this.row.out_place
          } else if (this.row.level == '2') {
            data.streets = this.row.out_place
          } else if (this.row.level == '1') {
            data.community = this.row.out_place
          }
        } else {
          data.community = this.row.out_place
        }
      } else if (str == 'cityPass' && this.row.event_type == '3') {
        // 跨街道调动
        if (this.row.level) {
          if (this.row.level == '3') {
            data.city = this.row.out_place
          } else if (this.row.level == '2') {
            data.streets = this.row.out_place
          } else if (this.row.level == '1') {
            data.community = this.row.out_place
          }
        } else {
          data.community = this.row.out_place
        }
      }
      data.common = '11'
      updatePersonCompanyCode(data).then(ret => {
        if (ret.data.errcode === 0) {

        } else {
          this.$Notice.error({
            title: '插入日志失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    back (row) {
      // this.row = row
      // this.modal = true
      updateEvaluationEntry({ open_state: '0', id: row.id }).then(ret => {
        if (ret.data.errcode === 0) {
          this.$Notice.success({
            title: '开启成功',
            // desc: ret.data.errmsg
          })
          this.init()
        } else {
          this.$Notice.error({
            title: '开启失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    // 查看详情
    getFlowItem (id) {
      this.obtainData()
      this.drawer1 = true
      let parasm = {
        id: id
      }
      selectEvaluationEntry(parasm).then(ret => {
        if (ret.data.errcode === 0) {
          this.formData = ret.data.data
          this.formData.category_name = ret.data.data.category_name
          this.showEdit = true
          this.formData.categoryNo = ret.data.data.category_no
          this.formData.start_time = this.timeParse(this.formData.start_time, '{y}-{m}-{d}')
          this.formData.end_time = this.timeParse(this.formData.end_time, '{y}-{m}-{d}')
          this.scoreList.entry_content[0] = ret.data.data.entry_content
          this.scoreList.entry_score[0] = ret.data.data.entry_score
          console.log('123', this.formData.category_name)
        } else {
          this.$Notice.error({
            title: '查询失败',
            desc: ret.data.errmsg
          })
        }
      })
    },
    init () {
      console.log('调用')
      this.searchInfo.loading1 = true
      this.obtainData()
      this.datalist = []
      let parasm = {
        categoryName: this.searchInfo.categoryName,
        categoryNo: this.searchInfo.categoryNo,
        start_time: this.searchInfo.start_time,
        end_time: this.searchInfo.end_time,
        'pageNo': this.searchInfo.currentPageNo,
        'pageSize': this.searchInfo.currentPageSize
      }

      selectEntry(parasm).then(ret => {
        if (ret.data.errcode === 0) {
          this.searchInfo.totalnum = ret.data.data.totalRecord
          // this.searchInfo.currentPageNo = ret.data.data.totalRecord 
          this.datalist = ret.data.data.results
          this.searchInfo.loading1 = false
        } else {
          this.$Notice.error({
            title: '查询失败',
            desc: ret.data.errmsg
          })
        }
      })  
    },
    changePagesize (pageSize) {
      this.searchInfo.currentPageSize = pageSize
      this.changePageNo()
    },
    changePageNo (pageNo) {
      this.searchInfo.currentPageNo = pageNo
      this.init()
    },
    // getMailList (grade, code) {
    //   // this.searchInfo['grade' + (index + 1)] = 0
    //   getOffice({ grade: grade, code: code }).then(res => {
    //     if (res.data.errcode === 0) {
    //       this.mailList1 = res.data.data
    //       let xiehui = {code: "1", name: "社区工作者协会", master: "社区工作者协会"}
    //       this.mailList1.push(xiehui)
    //       // this.mailList[index].unshift({ id: 0, title: '全部' })
    //       // this.$forceUpdate()
    //     } else {
    //       this.$Notice.error({ title: '获取信息失败', desc: '查询区域列表信息失败' })
    //     }
    //   })
    // },
    // getMailList2 (grade, code) {
    //   // this.searchInfo['grade' + (index + 1)] = 0
    //   getOffice({ code: code }).then(res => {
    //     if (res.data.errcode === 0) {
    //       if (grade === 4) {
    //         this.mailList2 = res.data.data
    //         let xiehui = {code: "1", name: "社区工作者协会", master: "社区工作者协会"}
    //         this.mailList2.push(xiehui)
    //       } else if (grade === 5) {
    //         this.mailList3 = res.data.data
    //       }
    //       // this.mailList[index].unshift({ id: 0, title: '全部' })
    //       // this.$forceUpdate()
    //     } else {
    //       this.$Notice.error({ title: '获取信息失败', desc: '查询区域列表信息失败' })
    //     }
    //   })
    // }
  },
  mounted () {
    this.init()
    console.log(this.$store.state.user.severUserInfo)
    if (this.companyGrade < 3) {
      // this.getMailList(2, null)
    } else if (this.companyGrade < 4) {
      this.getMailList2(4, this.companyCode)
    } else if (this.companyGrade < 5) {
      this.getMailList2(5, this.companyCode)
    }
  },
  computed: {
    companyGrade () {
      return this.$store.state.user.severUserInfo.company_grade
    },
    companyCode () {
      return this.$store.state.user.severUserInfo.company_code
    }
  }
}
</script>
